package com.itheima.day15.work1;



import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

public class ServerDemo2 {
    public static void main(String[] args) throws IOException {

        while (true) {
            DatagramSocket ds=new DatagramSocket(10001);
            byte[] bytes = new byte[1024];
            DatagramPacket  dp=new DatagramPacket(bytes,0,bytes.length);
            ds.receive(dp);
            byte[] data = dp.getData();
            int length = dp.getLength();
            System.out.println(new String(data,0,length));
            ds.close();
        }

    }
}
